package com.woniuxy.springboot.mybatis.controller;

import com.woniuxy.springboot.mybatis.pojo.Emp;
import com.woniuxy.springboot.mybatis.service.EmpService;
import io.swagger.models.Model;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping(value = "/emp")
public class EmpController2 {
    @Autowired
    private EmpService empService;
    @RequestMapping(value = "/listEmps")
    public ModelAndView listEmps(){
        ModelAndView modelAndView=new ModelAndView();
        List<Emp> emps = empService.findEmps();
        modelAndView.addObject("emps",emps);
        modelAndView.setViewName("empList");
        return modelAndView;
    }
}
